{% extends "admin/base/base.html" %}
{% block title %}
<title>用户管理</title>
{% endblock %}
{% block page_navbar %}
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页
    <span class="c-gray en">&gt;</span>
    管理员设定
    <span class="c-gray en">&gt;</span>
    管理员列表
    <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px"
       href="javascript:location.replace(location.href);" title="刷新"><i class="Hui-iconfont">&#xe68f;</i></a>
</nav>
{% endblock %}
{% block navbar %}
{% include "admin/base/system_navbar.html" %}
{% endblock %}
{% block content %}
<article class="cl pd-20" style="min-height: 51em;">
    <div class="cl pd-5 bg-1 bk-gray mt-20">
                <span class="l">
                    <a href="javascript:void(0);"
                       onclick="add('添加管理员','{{ url_for('admin.system_user_add') }}','800','680')"
                       class="btn btn-primary radius">
                        <i class="Hui-iconfont">&#xe600;</i> 添加管理员
                    </a>
                </span>
        <span class="r">共有数据：<strong>{{ count }}</strong> 条</span>
    </div>
    <table class="table table-border table-bordered table-bg">
        <thead>
        <tr class="text-c">
            <th width="25"><input type="checkbox" name="" value=""></th>
            <th width="40">ID</th>
            <th width="150">登录名</th>
            <th width="130">加入时间</th>
            <th width="100">是否管理员</th>
            <th width="100">操作</th>
        </tr>
        </thead>
        <tbody>
        {% for vo in result %}
        <tr class="text-c">
            <td><input type="checkbox" value="{{ vo.id }}" name="id"></td>
            <td>{{ vo.id }}</td>
            <td>{{ vo.name }}</td>
            <td>{{ vo.join_time }}</td>
            <td class="td-status">{% if vo.is_admin == 1 %}
                <span class="label label-success radius">是</span>{% elif vo.is_admin == 2 %}
                <span class="label label-success radius">否</span>{% endif %}
            </td>
            <td class="td-manage">
                <span class="l">
                    <a href="javascript:void(0);"
                       onclick="edit('编辑管理员','{{ url_for('admin.system_user_edit',id=vo.id) }}','800','680')"
                       class="btn btn-primary radius">
                        <i class="Hui-iconfont">&#xe600;</i> 编辑管理员
                    </a>
                </span>
            </td>
        </tr>
        {% endfor %}
        </tbody>
    </table>
</article>
{% endblock %}
{% block js %}
<script type="text/javascript"
        src="{{ url_for('static',filename='admin/lib/My97DatePicker/4.8/WdatePicker.js') }}"></script>
<script type="text/javascript"
        src="{{ url_for('static',filename='admin/lib/datatables/1.10.0/jquery.dataTables.min.js') }}"></script>
<script type="text/javascript" src="{{ url_for('static',filename='admin/lib/laypage/1.2/laypage.js') }}"></script>
<script type="text/javascript" src="{{ url_for('static',filename='admin/h-ui.admin/js/dialog.js') }}"></script>
<script type="text/javascript">
    $(document).ready(function () {
        $("#menu-system dt").addClass("selected");
        $("#menu-system dd").css("display", "block");
        $("#menu-system #manger_list").addClass("current");
        $("#system").addClass("current")
    });

    /*管理员-增加*/
    function add(title, url, w, h) {
        layer_show(title, url, w, h);
    }

    /*管理员-删除*/
    function admin_del(obj, id) {
        layer.confirm('确认要删除吗？', function (index) {
            //此处请求后台程序，下方是成功后的前台处理……

            $(obj).parents("tr").remove();
            layer.msg('已删除!', {icon: 1, time: 1000});
        });
    }

    /*管理员-编辑*/
    function edit(title, url,w, h) {
        layer_show(title, url, w, h);
    }

    /*管理员-停用*/
    function admin_stop(obj, url) {
        layer.confirm('确认要停用吗？', function (index) {
            $.ajax({
                type: 'POST',
                url: url,
                dataType: 'json',
                success: function (result) {
                    if (result.status === 1) {
                        $(obj).parents("tr").remove(); //这行代码的意思是将对象的上一级的tr一起移出
                        window.parent.parent.location.reload();
                        layer.msg(result.data);
                    } else {
                        dialog.error(result.data)
                    }
                }
            });
        });
    }

    /*管理员-停用*/
    function admin_start(obj, url) {
        layer.confirm('确认要启用吗？', function (index) {
            $.ajax({
                type: 'POST',
                url: url,
                dataType: 'json',
                success: function (result) {
                    if (result.status === 1) {
//                        $(obj).parents("tr").remove();
                        window.parent.parent.location.reload();
                        layer.msg(result.data)
                    } else {
                        dialog.error(result.data)
                    }
                }
            });
        });
    }

    /***
     * 管理员删除功能
     */
    function admin_del(obj, url) {
        layer.confirm('确认要删除吗？', function (index) {
            $.ajax({
                type: "post",
                url: url,
                dataType: "json",
                success: function (result) {
                    if (result.status === 1) {
                        $(obj).parents("tr").remove();
                        layer.msg(result.data, {icon: 1, time: 2000})
                    } else {
                        layer.msg(result.data, {icon: 5, time: 2000})
                    }
                }
            })
        })
    }
</script>
{% endblock %}